ARG IMAGE_TAG
FROM php:${IMAGE_TAG}

COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV COMPOSER_HOME=/srv/app/storage/composer
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
RUN composer self-update


ARG USER_ID
ARG USER_NAME

ENV TZ=Asia/Shanghai

ADD . /srv/app
WORKDIR /srv/app

RUN chmod +x bin/*.sh \
    && bin/add_user.sh \
    && bin/config_php_fpm.sh \
    && bin/config_system_mirror.sh \
    && bin/install_system_package.sh \
    && bin/install_php_extension.sh \
    && bin/clean.sh

RUN chown -R ${USER_NAME}:${USER_NAME} /srv/app    

USER ${USER_NAME}:${USER_NAME}
